package cn.com.cetccst.compliancecheck.worker;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

import cn.com.cetccst.compliancecheck.checker.CheckerManager;
import cn.com.cetccst.tools.log.CommonLogger;

public class CheckComplianceWorker extends Worker {

    public CheckComplianceWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @NonNull
    @Override
    public Result doWork() {
        try {
            CommonLogger.info("checking all compliance in worker");
            //协议里把check时间定为了一个，所以统一check的时候就指定一个时间
            CheckerManager.getInstance().checkAll(getApplicationContext());
            //表示任务执行成功
            return Result.success();
        } catch (Exception e) {
            //表示任务执行失败
            return Result.retry();
        }
    }
}
